@extends('admin.layouts.layout')
@section('content')
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-title">
                <h5>玩家信息</h5>
            </div>
            <div class="ibox-content">
                <form class="form-horizontal " action="{{route('userinfo.index')}}" method="post"
                      enctype="multipart/form-data"
                      onReset="resetForm();return false;">
                    {!! csrf_field() !!}
                    <table class="table-striped table-bordered table-hover table-condensed">
                        <tr class="b-group">
                            <th width="10%">
                                <label>渠道</label>
                            </th>
                            <td class="b-child">
                                <div style="max-height:6.5rem;overflow-y:scroll;">
                                    @include('widget.channel_radio')
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th width="10%">
                                <label>服务器</label>
                            </th>
                            <td class="b-child">
                                <div style="max-height:6.5rem;overflow-y:scroll;">
                                    @include('widget.server_radio')
                                </div>
                            </td>
                        </tr>
                        <tr class="b-group">
                            <td class="b-child" colspan="2">
                                <table class="table-striped table-bordered table-hover table-condensed">
                                    <tr class="b-group">
                                        <td class="form-inline">
                                            <label class="control-label"><a href="javascript:;"
                                                                            data-toggle="tooltip"
                                                                            data-placement="top"
                                                                            title="精确查询">玩家账号</a></label>
                                            <div class="input-daterange input-group">
                                                <input autocomplete="off" type="text" class="input-sm form-control"
                                                       name="uid"
                                                       value="{{app('request')->input('uid')}}"/>
                                            </div>
                                            @if ($errors->has('uid'))
                                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>{{$errors->first('uid')}}</span>
                                            @endif
                                        </td>
                                        <td class="form-inline">
                                            <label class="control-label"><a href="javascript:;"
                                                                            data-toggle="tooltip"
                                                                            data-placement="top"
                                                                            title="模糊查询">玩家名称</a></label>
                                            <div class="input-daterange input-group">
                                                <input autocomplete="off" type="text" class="input-sm form-control"
                                                       name="nickname"
                                                       value="{{app('request')->input('nickname')}}"/>
                                            </div>
                                            @if ($errors->has('nickname'))
                                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>{{$errors->first('nickname')}}</span>
                                            @endif
                                        </td>
                                        <td>
                                            @include('widget.query_and_refresh')
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <input type="hidden" name="page_size" value="{{$reqPageSize}}"/>
                </form>
                <table class="table table-striped table-bordered table-hover m-t-md tblData">
                    <thead>
                    <tr>
                        <th class="text-center">UID</th>
                        <th class="text-center">玩家账号</th>
                        <th class="text-center">创建服务器</th>
                        <th class="text-center">玩家名称</th>
                        <th class="text-center">封号时间</th>

                        <th class="text-center">禁言时间</th>
                        <th class="text-center">玩家创建时间</th>
                        <th class="text-center">最后登陆时间</th>
                        <th class="text-center">创建账号的IP</th>
                        <th class="text-center">上次登陆的IP</th>

                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody class="text-center" id="tbContainer">
                    @foreach($data as $key => $item)
                        <tr>
                            <td>{{$item['uid']}}</td>
                            <td>{{$item['account']}}</td>
                            <td>{{$item['server_id']}}</td>
                            <td>{{$item['nickname']}}</td>
                            <td>{{$item['ban_time']}}</td>

                            <td>{{unixTimeToDateTime($item['mute_time'])}}</td>
                            <td>{{unixTimeToDateTime($item['user_created_at'])}}</td>
                            <td>{{unixTimeToDateTime($item['last_login_at'])}}</td>
                            <td>{{$item['created_account_ip']}}</td>
                            <td>{{$item['last_login_ip']}}</td>
                            <td class="text-center">
                                <button class="btn btn-primary btn-xs" data-toggle="modal" data-uid="{{$item['account']}}"
                                        data-target="#myModal">查看
                                </button>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
                <div class="pull-left pagination m-t-no">
                    @include('widget.page',['reqPageSize'=>$reqPageSize])
                </div>
                <div class="pull-right pagination m-t-no">
                    <div class="text-center">
                        <?php
                        if (count($data) > 0) {
                            echo $data->appends([
                                'channel_id' => $reqChannelId,
                                'server_id' => $reqServerId,
                                'nickname' => app('request')->input('nickname'),
                                'uid' => app('request')->input('uid'),
                                'page_size' => app('request')->input('page_size'),
                            ])->links();
                        }
                        ?>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
    <script>
    </script>
    <link href="{{loadEdition('/admin/css/plugins/datapicker/bootstrap-datepicker.css')}}" rel="stylesheet">
    <link href="{{loadEdition('/admin/css/plugins/switchery/switchery.css')}}" rel="stylesheet">
@endsection
@section('js')
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width: 90%;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">玩家信息详情</h4>
                </div>
                <div class="modal-body" id="divModal" style="height: 55rem;">

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    {{--                    <button type="button" class="btn btn-primary">提交更改</button>--}}
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <script src="{{loadEdition('/admin/js/plugins/datapicker/bootstrap-datepicker.js')}}"></script>
    <script src="{{loadEdition('/admin/js/plugins/datapicker/bootstrap-datepicker.zh-CN.js')}}"></script>
    <script src="{{loadEdition('/admin/js/plugins/switchery/switchery.js')}}"></script>
    <script src="{{loadEdition('/js/global.js')}}"></script>
    <script>

        function resetForm() {
            window.location.href = '{{URL::full()}}';
        }

        //查看详情
        $('#myModal').on('show.bs.modal', function (e) {
            //debugger;
            var uid = e.relatedTarget.getAttribute('data-uid');
            var url = '{{route('userinfo.detail')}}?channel_id=' + $('input:checked[name="channel_id"]').val() + '&uid=' + uid + '&server_id=' + $('input:checked[name="server_id"]').val();
            var n = '<iframe class="J_iframe" name="iframe" width="100%" height="100%" src="' + url + '" frameborder="0" seamless></iframe>';
            $('#divModal').html(n);
        })
    </script>
@stop